package com.imooc.user.utils;


import com.imooc.user.enums.ResultEnum;
import com.imooc.user.vo.ResultVO;

/**
 * ResultVOUtil
 * 返回结果工具类
 * @author leon.cheng
 * @date 2018/11/20 15:19
 **/
public class ResultVOUtil {
    public static ResultVO success(Object object){
        ResultVO resultVO = new ResultVO();
        resultVO.setData(object);
        resultVO.setCode(0);
        resultVO.setMsg("成功");
        return resultVO;
    }
    public static ResultVO success()
    {
        return success(null);
    }
    public  static ResultVO error(Integer code, String msg){
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(code);
        resultVO.setMsg(msg);
        return resultVO;
    }

    public  static ResultVO error(ResultEnum resultEnum){
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(resultEnum.getCode());
        resultVO.setMsg(resultEnum.getMessage());
        return resultVO;
    }
}
